'use strict';

var debug = require('debug'),
  log = debug('yozh:config:log'),
  error = debug('yozh:config:error'),
  verbose = debug('yozh:config:verbose');

module.exports = exports = function mySocketFunc(opts) {
  var mySocket = {};
  mySocket.io = false;

  mySocket.init = function(server) {
    this.io = opts.socketIo(server);
    this.ioListen();
  };

  // major socket listening method
  mySocket.ioListen = function() {
    var that = this;
    this.io.on('connection', function(socket) {
      log('a client connected', socket.id);
      that.disconnect(socket);
    });
  };

  mySocket.disconnect = function(socket) {
    var that = this;
    socket.on('disconnect', function() {
      log('exit socket', socket.id);
      that.io.emit('exit socket', socket.id);
    });
  };
  return mySocket;
};

